//
//  JSSettingViewController.m
//  NiubilityProject
//
//  Created by Apple on 2017/12/2.
//  Copyright © 2017年 Apple. All rights reserved.
//

#import "JSSettingViewController.h"
#import "JSResetPwdViewController.h"
#import "JSPwdSeetingVC.h"
@interface JSSettingViewController ()

@end

@implementation JSSettingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = JSLocalizedString(@"seetingLoca");
    NSArray *data = @[
                      @{@"icon":@"facebook_Setting",
                        @"title":NSStringFormat(@"%@Facebook", JSLocalizedString(@"binding"))
                        },
                      @{@"icon":@"me_email",
                        @"title":JSLocalizedString(@"bindingEmail")
                        },
                      @{@"icon":@"me_pwd",
                        @"title":JSLocalizedString(@"settingPassword")
                        },
                      @{@"icon":@"me_out",
                        @"title":JSLocalizedString(@"PullOut")
                        },
                      ];
    [self.dataSource addObjectsFromArray:data];
}

- (void)initTableView{
    [super initTableView];
    self.isHidenFooterRefresh = YES;
    self.isHidenHeaderRefresh = YES;
    self.tableView.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0);
}
-(NSInteger )tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.dataSource.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
        cell.textLabel.font = UIFontMake(14);
        cell.textLabel.textColor = JS_colorWithHex(kColorBlack3);
        cell.accessoryType = QMUIStaticTableViewCellAccessoryTypeDisclosureIndicator;
    }
    NSDictionary *dic = self.dataSource[indexPath.row];
    cell.imageView.image = UIImageMake(dic[@"icon"]);
    cell.textLabel.text  = dic[@"title"];
    return cell;
}
-(UIImage *)navigationBarShadowImage{
    return [UIImage qmui_imageWithColor:JS_colorWithHex(kBodyLineColor) size:CGSizeMake(0, flat(0.5)) cornerRadius:0];
}
- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if (indexPath.row == 0) { // 绑定facebook
        
    }else if (indexPath.row == 1){ // 绑定邮箱
        JSResetPwdViewController *vc = [[JSResetPwdViewController alloc] init];
        JS_VC_PUSHVC_ANIMATION(YES);
    }else if (indexPath.row == 2){ // 设置密码
        JSPwdSeetingVC *vc = [[JSPwdSeetingVC alloc] init];
        JS_VC_PUSHVC_ANIMATION(YES);
    }else if (indexPath.row == 3){ // 退出
         [JSNetManager js_courrentProjectRequestWithMouth:@"logout" cache:NO ifShowFinishStatu:NO parameters:@{@"token":userManager.curUserInfo.token}.mutableCopy successBlock:nil failureBlock:nil];
        [userManager logout:^(BOOL success, NSString *des) {
           
        }];
    }
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return kRealValue(50);
}
@end
